package com.zy.openchat.core.model.setting;

import com.zy.openchat.util.Common;

import java.util.ArrayList;
import java.util.List;

public class UserPrivacySettingRules {

    public List<UserPrivacySettingRule> rules;

    public UserPrivacySettingRules(int chooseIndex) {
        String rule;
        switch (chooseIndex){
            case 0:
                rule = UserPrivacySettingRule.ALL;
                break;
            case 1:
                rule = UserPrivacySettingRule.CONTACTS;
                break;
            default:
                rule = UserPrivacySettingRule.NONE;
                break;
        }
        rules = new ArrayList<>();
        rules.add(new UserPrivacySettingRule(rule));
    }

    public int getRuleIndex(){
        if(Common.isEmpty(rules)){
            return -1;
        }
        String rule = rules.get(0).type;
        switch (rule){
            case UserPrivacySettingRule.ALL:
                return 0;
            case UserPrivacySettingRule.CONTACTS:
                return 1;
            case UserPrivacySettingRule.NONE:
                return 2;
            default:
                return -1;
        }
    }

}
